package com.cloud.item.client;

import com.cloud.item.client.fallback.OrderClientFallBack;
import com.cloud.item.client.isolation.OrderThreadIsolationConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Map;

/**
 * 远程调用接口
 * name: 服务名
 * fallback: 降级处理类
 */
@FeignClient(name = "order-service", fallback = OrderClientFallBack.class,fallbackFactory = OrderThreadIsolationConfig.class)
public interface OrderClient {

    /**
     * 测试hystrix远程调用
     *
     * @param flag
     * @return
     */
    @GetMapping("/order/testHystrix/{flag}")
    public Map testHystrix(@PathVariable("flag") String flag);

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    @GetMapping("/order/{id}")
    public Map findById(@PathVariable Integer id);

    /**
     * 查询全部
     *
     * @return
     */
    @GetMapping("/order/")
    public Map findAll();
}
